/*
 * @Author: ljc
 * @Date: 2023-04-26 14:13:41
 * @LastEditors: LiSong
 * @LastEditTime: 2024-11-19 11:24:38
 * @Description:储备管理和备选管理 撤销 送审 审核 退回
 */
import { defAxios as request } from '@/utils/http';

export function useProjectApi() {
    return {
        /**
         * 通过申报Id删除备选项目
         * @param {*} params 
         * @returns 
         */
        deleteProResPerfect(params) {
            return request({
                url: '/proResPerfect/deleteProResPerfect',
                method: 'POST',
                data: params,
            });
        },
        improveProHandleTask (params) {
            return request({
                url: '/proResPerfect/handleTask',
                method: 'post',
                data: params,
            });
        },
    };
}

export function useProjectInfoApi() {
    return {
        getProjectInfo({ proId, applyId, formCode, isAddStatus, busiType }, final) {
            return new Promise((resolve, reject) => {
                const params = { proId, formCode, busiType };
                if (applyId) params['applyId'] = applyId;
                if (isAddStatus) params['isAddStatus'] = 1;
                request({
                    url: '/proResApply/queryReserveProjectByProId',
                    method: 'POST',
                    data: params,
                }).then((res) => {
                        const { code, data, msg } = res;
                        if (code === 200) {
                            resolve(data);
                        } else {
                            console.error('获取项目信息出错！', msg)
                            reject(msg);
                        }
                    })
                    .catch((err) => {
                        console.error('获取项目信息出错！', err);
                        reject(err);
                    })
                    .finally(() => {
                        if (final) {
                            final();
                        }
                    });
            });
        },
    };
}
